﻿namespace Class06_类和对象
{
    internal class Program
    {
        static void Main(string[] args)//main是程序的入库
        {
            // var account=new BankAccount("Kendra",1000);
            var account = new BankAccount("Kendra",1000);
            Console.WriteLine($"Account {account.Number} was created for {account.Owner} with {account.Balance}");
            account.MakeWithdrawal(500, DateTime.Now, "Rent payment");
            Console.WriteLine(account.Balance);
            account.MakeDeposit(100, DateTime.Now, "Friend paid me back");
            Console.WriteLine(account.Balance);
            
            Console.WriteLine(account.GetAccountHistory());



            // Test for a negative balance.
            try
            {
                account.MakeWithdrawal(750, DateTime.Now, "Attempt to overdraw");
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine("Exception caught trying to overdraw");
                Console.WriteLine(e.ToString());
            }

            //存一个负值的测试
            //BankAccount invalidAccount;
            //try
            //{
            //    invalidAccount = new BankAccount("invalid", -55);//创建一个新的银行账户
            //}
            //catch (ArgumentOutOfRangeException e)
            //{
            //    Console.WriteLine("Exception caught creating account with negative balance");
            //    Console.WriteLine(e.ToString());
            //    return;
            //}



        }






        static void Printlist(List<string> lists)
        {
            foreach (var list in lists)
            {
                Console.WriteLine(list);
            }
        }
    }
}